<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2018-05-24
 * Time: 17:44
 */

namespace app\api\model;


class Refund extends BaseModel
{
    protected $table = 'we_refund';
    //        隐藏不需要的字段
    protected $hidden = ['create_time', 'update_time', 'delete_time', 'id', 'oid', 'uid', '', '', '' ];
    //    自动写入时间戳
    protected $autoWriteTimestamp = true;

    //    保存图片
    public static function saveImages($files){
        $images_path = config('setting.refund_images');
        $img_urls = self::saveFiles($files,$images_path);
        return $img_urls;
    }
    // 查询此订单用户是否申请退款
    public static function getRefundByOID($oid, $uid){
        $refund_info = self::with('order')->where('oid', '=', $oid)->where('uid', '=', $uid)->find();
        return $refund_info;
    }
    // 关联订单表
    public function order(){
        return $this->belongsTo('Order', 'oid', 'id');
    }

}